$(function () {
  $(".direction a").on("click", function () {
    $("#search_cate").val($(this).attr("attr"));
    var search_cate = $("search_cate").val();
    var opposite = $(this).index();
    $(".direction a").css({ "background-color": "#fff" });
    $(".direction a").css({ color: "#5F5A5A" });
    $(".direction a").eq(opposite).css({ "background-color": "#02C1D0" });
    $(".direction a").eq(opposite).css({ color: "#fff" });
  });

  $(".direction a").on("click", function () {
    var inputKey = $(this).index();
    if (inputKey == 0) {
      $(".lookup input").attr("placeholder", "璇疯緭鍏ユ偍瑕佹悳绱㈢殑璇剧▼");
    } else if (inputKey == 1) {
      $(".lookup input").attr("placeholder", "璇疯緭鍏ユ偍瑕佹悳绱㈢殑鏈烘瀯");
    } else if (inputKey == 2) {
      $(".lookup input").attr("placeholder", "璇疯緭鍏ユ偍瑕佹悳绱㈢殑鑰佸笀");
    }
  });

  $("[name='select-list'] li:first-child").addClass("classify-cla");
  $("[name='select-list'] li:first-child").css("color", "#00BED4");
  $("[name='select-box'] .compostion-books-box").hide();
  $("[name='select-box'] .compostion-books-box:first-child").show();
  $(document).on("mouseover", '[name="select-list"] li', function () {
    $(this).addClass("classify-cla").siblings().removeClass("classify-cla");
    $(this).css("color", "#00BED4").siblings().css("color", "#626262");
    $(this)
      .parent()
      .parent()
      .parent()
      .parent()
      .siblings()
      .find(".compostion-books-box")
      .stop(true, true)
      .hide()
      .eq($(this).index())
      .show();
  });

  $(".swiper-slide").addClass("swiper-no-swiping");

  $(".direction a").on("click", function () {
    var inputKey = $(this).index();
    if (inputKey == 0) {
      $(".lookup input").attr("placeholder", "璇疯緭鍏ユ偍瑕佹悳绱㈢殑璇剧▼");
    } else if (inputKey == 1) {
      $(".lookup input").attr("placeholder", "璇疯緭鍏ユ偍瑕佹悳绱㈢殑鏈烘瀯");
    } else if (inputKey == 2) {
      $(".lookup input").attr("placeholder", "璇疯緭鍏ユ偍瑕佹悳绱㈢殑鑰佸笀");
    }
  });

  /* 鍘熺悊锛氱Щ鍔ㄧ殑鏄鏈夋墍鏈夊浘鐗囩殑ul*/
  /*ul鍚戝乏绉诲姩锛屽嚭鐜颁笅涓€寮犲浘鐗囷紝鐒跺悗绉婚櫎绗竴寮犲浘鐗囧苟鍏嬮殕绗竴寮犲浘鐗囧姞鍒囧姞鍦╱l鍚庨潰锛岄噸缃畊l鐨刴arginLeft*/
  function showNextT(time) {
    $(".mechanism-mec-box").animate(
      { marginLeft: "-170px" },
      time,
      "linear",
      function () {
        $(".mechanism-mec-box a:first")
          .remove()
          .clone()
          .appendTo(".mechanism-mec-box");
        $(this).css(
          "marginLeft",
          "11px"
        ); /*娓呴櫎浜嗙涓€寮狅紝鍒欑浜屽紶浼氳嚜鍔ㄥ悜鍓嶇Щ鍔ㄥ彉涓虹涓€寮�,绗笁寮犲崰棰嗙浜屽紶鐨勪綅缃紝濡傛灉涓嶆仮澶島l鐨刴arginleft涓�0锛屽垯浼氭樉绀虹涓夊紶鍥剧墖*/
      }
    );
  }
  function showNext() {
    showNextT(200);
  }

  /*   var timer;
	    timer=setInterval(showNext,4000);
	    //榧犳爣鎮仠锛屽仠姝㈣疆鎾�
	    $(".mechanism-box").hover(function(){
	        clearInterval(timer);
	    },function(){
	        timer=setInterval(showNext,4000);
	    });*/

  $(".news-other span").on("mouseover", function () {
    var newsPos = $(this).index();
    $(".news-other-content").hide();
    $(".news-other-content").eq(newsPos).show();
    $(".news-other span").css("border-bottom", "1px solid #A2A79C");
    $(".news-other span").eq(newsPos).css("border-bottom", "1px solid #6DD9DE");
  });

  var imgList = [], // 椤甸潰鎵€鏈塱mg鍏冪礌闆嗗悎
    delay, // setTimeout 瀵硅薄
    offset, //鍋忕Щ閲忥紝鐢ㄤ簬鎸囧畾鍥剧墖璺濈鍙鍖哄煙澶氬皯璺濈锛岃繘琛屽姞杞�
    time, // 寤惰繜杞藉叆鏃堕棿
    _selector; // 閫夋嫨鍣� 榛樿涓� .m-lazyload
  function _isShow(el) {
    var coords = el.getBoundingClientRect();
    return (
      (coords.top >= 0 && coords.left >= 0 && coords.top) <=
      (window.innerHeight || document.documentElement.clientHeight) +
        parseInt(offset)
    );
  }
  function _loadImage() {
    for (var i = imgList.length; i--; ) {
      var el = imgList[i];
      if (_isShow(el)) {
        el.src = el.getAttribute("data-src");
        el.className = el.className.replace(
          new RegExp(
            "(\\s|^)" + _selector.substring(1, _selector.length) + "(\\s|$)"
          ),
          " "
        );
        imgList.splice(i, 1);
      }
    }
  }
  function _delay() {
    clearTimeout(delay);
    delay = setTimeout(function () {
      _loadImage();
    }, time);
  }
  function ImageLazyload(selector, options) {
    var defaults = options || {};
    offset = defaults.offset || 0;
    time = defaults.time || 250;
    _selector = selector || ".m-lazyload";
    this.getNode();
    _delay(); //閬垮厤棣栨鍔犺浇鏈Е鍙憈ouch浜嬩欢,涓诲姩瑙﹀彂涓€娆″姞杞藉嚱鏁�
    if (defaults.iScroll) {
      defaults.iScroll.on("scroll", _delay);
      defaults.iScroll.on("scrollEnd", _delay);
    } else {
      window.addEventListener("scroll", _delay, false);
    }
  }
  ImageLazyload.prototype.getNode = function () {
    imgList = [];
    var nodes = document.querySelectorAll(_selector);
    for (var i = 0, l = nodes.length; i < l; i++) {
      imgList.push(nodes[i]);
    }
  };
});

$(".modular").on("click", function () {
  $(".win").animate({ marginLeft: "0" });
});
$(".window-shadow").on("click", function () {
  $(".win").animate({ marginLeft: "-100%" });
});
